<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.t.codebook.mapper.${upperDataKey}Mapper">


    <sql id="queryCondition">
        <#list table.fieldInfos as field >
                <if test="dto.${field.dataFieldName} !=null and dto.${field.dataFieldName} !=''">
                    AND ${table.alias}.${field.dataFieldName} = ${"#{"+field.fieldName+"}"}
                </if>
        </#list>
    </sql>


    <select id="select${dataKey}ListByCondition" resultType="com.t.codebook.model.vo.${upperDataKey}VO">
        select
        <#list table.fieldInfos as field>
            ${field.dataFieldName} ,
        </#list>
        from
        ${table.tableName} as ${table.alias}
        <include refid="queryCondition">
        </include>
    </select>



    <select id="select${dataKey}ById"  resultType="com.t.codebook.model.vo.${upperDataKey}VO">
        select
        <#list table.fieldInfos as field >
            ${field.dataFieldName} ,
        </#list>
        from
        ${table.tableName} as ${table.alias}
        where ${table.alias}.id = ${table.tableKey}
    </select>



</mapper>